#include "gameentity.h"
#include "planet.h"

gecko::Entity::UpdateReturn GameEntity::Update( float dt )
{
	return Entity::Update(dt);
}

void GameEntity::AccumulateGravityForce( const GameEntity & other )
{
	// F = (G * (m1 * m2)) / (r * r)

	gecko::Vector3f myPosition;
	gecko::Vector3f otherBodyPosition;

	m_body->GetPosition(myPosition);
	other.m_body->GetPosition(otherBodyPosition);

	gecko::Vector3f forceActionLine = myPosition - otherBodyPosition;
	float distanceSq = (forceActionLine).MagnitudeSq();
	const float G = 0.1f; // gravitational constant
	float gravForce = (G * (m_mass * other.m_mass)) / distanceSq;

	forceActionLine.Normalise();
	forceActionLine *= gravForce;

	m_bodyForces -= forceActionLine;
}

void GameEntity::GetPosition( gecko::Vector3f & position )
{
	m_body->GetPosition(position);
}

float GameEntity::GetAngle()
{
	return m_body->GetRotation();
}

